package co.edu.poli.ficb.agl.automatable.gui;

import org.apache.commons.collections15.Predicate;

import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.util.Context;
import edu.uci.ics.jung.graph.util.EdgeType;

public final class MyDirectionDisplayPredicate<V,E> implements Predicate<Context<Graph<V,E>,E>> {
	protected boolean show_d;
	protected boolean show_u;

	public MyDirectionDisplayPredicate(boolean show_d, boolean show_u)
	{
		this.show_d = show_d;
		this.show_u = show_u;
	}

	public void showDirected(boolean b)
	{
		show_d = b;
	}

	public void showUndirected(boolean b)
	{
		show_u = b;
	}

	public boolean evaluate(Context<Graph<V,E>,E> context)
	{
		Graph<V,E> graph = context.graph;
		E e = context.element;
		if (graph.getEdgeType(e) == EdgeType.DIRECTED && show_d) {
			return true;
		}
		if (graph.getEdgeType(e) == EdgeType.UNDIRECTED && show_u) {
			return true;
		}
		return false;
	}
}